var http=require("http");
var url=require("url");
var fs=require("fs");


var server=http.createServer(function (req,res) {
});

server.on("request",function (req,res) {
    console.log("客户已接入！");
    var urlObj=url.parse(req.url);
    console.log();

     res.writeHead(200,"OK",{"content-type":"text/html;charset=utf-8"});
     if(urlObj.path!="/favicon.ico"){
         if(urlObj.path=="/"){
             fs.readFile("./html/index.html",function (err,data) {
                 var val=data.toString();
                 res.write(val);
                 res.end();
             });
         }else{
              fs.readFile("./html"+urlObj.path+".html",function (err,data) {
              var val=data.toString();
              res.write(val);
              res.end();
              })
         }
     }


});
server.listen(2000);